<template>
	<view class="pageBg">
		<RegChoose v-if="utype == 0"></RegChoose>
		<RegCompany v-if="utype == 1"></RegCompany>
		<RegPersonal v-if="utype == 2"></RegPersonal>
	</view>
</template>

<script>
	import RegChoose from './components/RegChoose'
	import RegCompany from './components/RegCompany'
	import RegPersonal from './components/RegPersonal'
	import {
		onShareAppMessage,
		onShareTimeline
	} from '@/utils/share.js'
	export default {
		name: 'Reg',
		components: {
			RegChoose,
			RegCompany,
			RegPersonal
		},
		data() {
			return {
				utype_alias: '',
				utype: 2
			}
		},
		onLoad(options) {
			this.utype_alias = options.utype_alias
			this.updateAlias()
		},
		onShareAppMessage() {
			if (this.utype == 1) { //企业
				return onShareAppMessage({
					url: '/member/Reg?utype_alias='+'company',
					alias: "reg_company",
					info: {}
				})
			} else if (this.utype == 2) { //个人
				return onShareAppMessage({
					url: '/member/Reg?utype_alias='+'personal',
					alias: "reg_personal",
					info: {}
				})
			}
		},
		onShareTimeline() {
			if (this.utype == 1) { //企业
				return onShareTimeline({
					url: '/member/Reg?utype_alias='+'company',
					alias: "reg_company",
					info: {}
				})
			} else if (this.utype == 2) { //个人
				return onShareTimeline({
					url: '/member/Reg?utype_alias='+'personal',
					alias: "reg_personal",
					info: {}
				})
			}
		},
		methods: {
			updateAlias() {
				console.log(this.utype_alias,'this.utype_alias')
				this.utype =
					this.utype_alias === 'company' ?
					1 :
					this.utype_alias === 'personal' ?
					2 :
					0
			}
		}
	}
</script>